<template>
  <div class="jianzhimaoAgentSign">
    <c-title :hide="false" :text="`代理签约`"></c-title>
    <div class="lis">
      <div class="rule">
        <div class="ruleLeft">手机号码:</div>
        <div class="ruleRighe">
          <van-field v-model="form.mobile" placeholder="输入手机号码" />
        </div>
      </div>
      <div class="rule">
        <div class="ruleLeft">身份证:</div>
        <div class="ruleRighe">
          <van-field v-model="form.idcard" placeholder="输入身份证" />
        </div>
      </div>
      <div class="rule">
        <div class="ruleLeft">姓名:</div>
        <div class="ruleRighe">
          <van-field v-model="form.name" placeholder="姓名" />
        </div>
      </div>
    </div>
    <div class="tips">注: 姓名必须与会员基本信息姓名保持一致,否则提现导致失败.</div>
    <div class="bandSave" @click="bind">设置签约代理</div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      form: {}
    };
  },
  activated() {
    this.getData();
  },
  methods: {
    getData() {
      $http
        .get("plugin.jianzhimao-withdraw.frontend.member-info.electronic-mobile", {}, "")
        .then(response => {
          if (response.result == 0) {
            this.$toast(response.msg);
          } else {
            this.form = response.data;
          }
        })
        .catch(err => {
          console.error(err);
        });
    },
    bind() {
      console.log(this.fun.isTextEmpty(this.form.idcard));
      if (this.fun.isTextEmpty(this.form.mobile)) {
        this.$toast("请填写手机号码");
        return;
      }
      if (this.fun.isTextEmpty(this.form.idcard)) {
        this.$toast("请填写身份证");
        return;
      }
      if (this.fun.isTextEmpty(this.form.name)) {
        this.$toast("请填写姓名");
        return;
      }
      $http
        .get("plugin.jianzhimao-withdraw.frontend.member-info.electronic-user", this.form, "")
        .then(response => {
          if (response.result == 0) {
            this.$toast(response.msg);
          } else {
            this.$router.go(-1);
            this.$toast(response.msg);
          }
        })
        .catch(err => {
          console.error(err);
        });
    }
  }
};
</script>
<style lang="scss" scoped>
.tips{
  text-align: left;
  font-size: 0.8rem;
  color: #f96d20;
  margin-top: 0.625rem;
  padding: 0 0.94rem;
}
.bandSave {
  width: 20rem;
  height: 2.5rem;
  background-color: #f96d20;
  border-radius: 1.25rem;
  font-size: 0.94rem;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  margin-top: 2rem;
}
.lis {
  .rule {
    display: flex;
    align-items: center;
    padding: 0 0.94rem;
    background: #fff;
  }
}
</style>
